/*
 * File: AndroidSound
 * Created: 13-JUN-2011
 * Author: Colin Gall-McDaid
 * 
 * Description: Android implementation of the Sound framework.
 */
package com.gallsoft.games.framework.impl;

import android.media.SoundPool;

import com.gallsoft.games.framework.Sound;

public class AndroidSound implements Sound {

    private int soundId;
    private SoundPool soundPool;

    /**
     * Constructor
     * 
     * @param soundPool Android SoundPool
     * @param soundId Android SoundPool ID
     */
    public AndroidSound(SoundPool soundPool, int soundId) {
        this.soundId = soundId;
        this.soundPool = soundPool;
    }

    /**
     * Play this sound effect
     * 
     * @param volume sound effect volume
     */
    public void play(float volume) {
        soundPool.play(soundId, volume, volume, 0, 0, 1);
    }

    /**
     * Dispose of this sound effect
     */
    public void dispose() {
        soundPool.unload(soundId);
    }

}
